package cc.mrbird.febs.accounting.controller;

import cc.mrbird.febs.accounting.service.IEstimateHistoryService;
import cc.mrbird.febs.common.controller.BaseController;
import cc.mrbird.febs.common.entity.FebsResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 *  Controller
 *
 * @author hbh
 * @date 2022-02-17 23:27:01
 */
@Slf4j
@Validated
@Controller
@RequiredArgsConstructor
public class EstimateHistoryController extends BaseController {
    
    private final IEstimateHistoryService estimateHistoryService;


    @GetMapping("estimateHistory/query")
    @ResponseBody
    public FebsResponse query() {
        return new FebsResponse().success().data(estimateHistoryService.queryByYearMonth());
    }

    @PostMapping("estimateHistory/confirm")
    @ResponseBody
    @RequiresPermissions("confirm")
    public FebsResponse confirm(String year, String historyMonth) {
        estimateHistoryService.confirm(year, historyMonth);
        return new FebsResponse().success();
    }

    @PostMapping("estimateHistory/queryConfirmed")
    @ResponseBody
    public FebsResponse queryConfirmed() {
        return new FebsResponse().success().data(estimateHistoryService.queryConfirmed());
    }
}
